import pygame
import sys
from init_map import InitMap


class Map(InitMap):
    def __init__(self, *args):
        InitMap.__init__(self)

        self.shop1 = pygame.image.load("../资源/图片/商店1.jpg").convert_alpha()
        self.shop2 = pygame.image.load("../资源/图片/商店2.jpg").convert_alpha()
        self.shop3 = pygame.image.load("../资源/图片/商店3.jpg").convert_alpha()
        self.key_yellow = pygame.image.load("../资源/图片/黄钥匙.jpg").convert_alpha()
        self.key_blue = pygame.image.load("../资源/图片/蓝钥匙.jpg").convert_alpha()
        self.key_red = pygame.image.load("../资源/图片/红钥匙.jpg").convert_alpha()
        self.door_yellow = pygame.image.load("../资源/图片/黄门.jpg").convert_alpha()
        self.door_blue = pygame.image.load("../资源/图片/蓝门.png").convert_alpha()
        self.door_red = pygame.image.load("../资源/图片/红门.jpg").convert_alpha()
        self.hp_red = pygame.image.load("../资源/图片/红药.jpg").convert_alpha()
        self.hp_blue = pygame.image.load("../资源/图片/蓝药.jpg").convert_alpha()
        self.gem_blue = pygame.image.load("../资源/图片/蓝宝石.jpg").convert_alpha()
        self.gem_red = pygame.image.load("../资源/图片/红宝石.jpg").convert_alpha()
        self.steel_shield = pygame.image.load("../资源/图片/钢盾.png").convert_alpha()
        self.dark_guard = pygame.image.load("../资源/图片/冥卫兵.png").convert_alpha()
        self.senior_guard = pygame.image.load("../资源/图片/高级卫兵.png").convert_alpha()
        self.animal_warrior = pygame.image.load("../资源/图片/兽面武士.png").convert_alpha()
        self.double_sword = pygame.image.load("../资源/图片/双手剑士.png").convert_alpha()

        self.hero_pos = (1, 10)
        self.up_pos = (10, 10)
        self.down_pos = (0, 10)
        self.variable_pos = {
            (0, 3): (self.door_yellow, '黄门'),
            (0, 5): (self.door_yellow, '黄门'),
            (2, 3): (self.door_yellow, '黄门'),
            (4, 3): (self.door_yellow, '黄门'),
            (6, 3): (self.door_yellow, '黄门'),
            (10, 5): (self.door_yellow, '黄门'),
            (3, 5): (self.door_blue, '蓝门'),
            (7, 5): (self.door_blue, '蓝门'),
            (9, 3): (self.door_blue, '蓝门'),
            (2, 9): (self.door_red, '红门'),
            (8, 9): (self.door_red, '红门'),
            (5, 8): (self.shop2, '11楼商店'),
            (2, 0): (self.key_yellow, '黄钥匙'),
            (2, 1): (self.key_yellow, '黄钥匙'),
            (2, 2): (self.key_yellow, '黄钥匙'),
            (4, 0): (self.key_blue, '蓝钥匙'),
            (4, 1): (self.key_blue, '蓝钥匙'),
            (4, 2): (self.key_blue, '蓝钥匙'),
            (6, 0): (self.key_red, '红钥匙'),
            (6, 1): (self.key_red, '红钥匙'),
            (6, 2): (self.key_red, '红钥匙'),
            (0, 0): (self.hp_red, '红药'),
            (0, 1): (self.hp_red, '红药'),
            (0, 2): (self.hp_red, '红药'),
            (4, 9): (self.hp_red, '红药'),
            (6, 9): (self.hp_red, '红药'),
            (4, 6): (self.hp_blue, '蓝药'),
            (6, 6): (self.hp_blue, '蓝药'),
            (8, 0): (self.hp_blue, '蓝药'),
            (10, 0): (self.hp_blue, '蓝药'),
            (0, 6): (self.gem_blue, '蓝宝石'),
            (0, 7): (self.gem_blue, '蓝宝石'),
            (0, 8): (self.gem_blue, '蓝宝石'),
            (10, 6): (self.gem_red, '红宝石'),
            (10, 7): (self.gem_red, '红宝石'),
            (10, 8): (self.gem_red, '红宝石'),
            (9, 0): (self.steel_shield, '钢盾'),
            (2, 7): (self.animal_warrior, '兽面武士'),
            (2, 8): (self.animal_warrior, '兽面武士'),
            (8, 7): (self.animal_warrior, '兽面武士'),
            (8, 8): (self.animal_warrior, '兽面武士'),
            (8, 1): (self.dark_guard, '冥卫兵'),
            (9, 2): (self.dark_guard, '冥卫兵'),
            (10, 1): (self.dark_guard, '冥卫兵'),
            (3, 6): (self.dark_guard, '冥卫兵'),
            (7, 6): (self.dark_guard, '冥卫兵'),
            (9, 1): (self.senior_guard, '高级卫兵'),
            (5, 6): (self.double_sword, '双手剑士'),
        }

    def fixed_brick(self):
        self.draw(self.upstairs, self.up_pos[0], self.up_pos[1])
        self.dic[self.up_pos] = '上楼'
        self.draw(self.downstairs, self.down_pos[0], self.down_pos[1])
        self.dic[self.down_pos] = '下楼'
        self.draw(self.shop1, 4, 8)
        self.dic[(4, 8)] = '墙'
        self.draw(self.shop3, 6, 8)
        self.dic[(6, 8)] = '墙'
        for i in [(1, 0), (1, 1), (1, 2), (1, 3), (3, 0), (3, 1), (3, 2), (3, 3), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4),
                  (5, 5), (4, 5), (6, 5), (2, 5), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (0, 9), (7, 0), (7, 1), (7, 2),
                  (7, 3), (8, 3), (10, 3), (8, 5), (9, 5), (9, 6), (9, 7), (9, 8), (9, 9), (10, 9), (3, 9), (3, 8), (3, 7),
                  (4, 7), (5, 7), (6, 7), (7, 7), (7, 8), (7, 9)]:
            self.draw(self.wall, i[0], i[1])
            self.dic[(i[0], i[1])] = '墙'
        for i in self.ls:
            self.screen.blit(self.road, i)
            self.dic[(int((i[0]-375)/48), int((i[1]-25)/48))] = '路'
